package com.nineclock.approve.controller;

import com.nineclock.api.approve.ApproveDefinitionControllerApi;
import com.nineclock.approve.dto.ApproveDefinitionSaveDto;
import com.nineclock.approve.dto.ApproveGroupDefinitionDto;
import com.nineclock.approve.service.ApproveDefinitionService;
import com.nineclock.common.entity.Result;
import com.nineclock.common.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/approve")
public class ApproveDefinitionController implements ApproveDefinitionControllerApi {


    @Autowired
    private ApproveDefinitionService approveDefinitionService;



    @Override
    @GetMapping("/seq")
    public Result<String> seq() {
        return Result.success(UUIDUtils.getUUID());
    }

    @Override
    @GetMapping("/approveGroupDefinition")
    public Result<List<ApproveGroupDefinitionDto>> queryApproveGroupDefinition() {
        List<ApproveGroupDefinitionDto> definitionQueryOutList = approveDefinitionService.queryApproveGroupDefinition();
        return Result.success(definitionQueryOutList);

    }

    @Override
    @PostMapping("/approveDefinition")
    public Result saveApproveDefinition(@RequestBody ApproveDefinitionSaveDto approveDefinitionSaveDto){
        approveDefinitionService.saveApproveDefinition(approveDefinitionSaveDto);
        return Result.success();
    }

}   